﻿using Microsoft.EntityFrameworkCore;
using Stu_sys.Entity;
using Stu_sys.EntityConfig;

namespace Stu_sys
{
    public class MysqlContext: DbContext
    {
        public MysqlContext(DbContextOptions<MysqlContext> options) : base(options)
        {

        }
        public DbSet<User> Users { get; set; }
        public DbSet<Role> Roles { get; set; }
        public DbSet<Department> Departments { get; set; }
        public DbSet<ClassEntity> ClassEntities { get; set; }
        public DbSet<ClassRoom> ClassRooms { get; set; }
        public DbSet<Exam> Exams { get; set; }
        public DbSet<Grade> Grades { get; set; }
        public DbSet<Permission> Permissions { get; set; }
        public DbSet<Reward> Rewards { get; set; }
        public DbSet<RolePermission> RolePermissions { get; set; }
        public DbSet<Score> Scores { get; set; }
        public DbSet<Student> Students { get; set; }
        public DbSet<Subject> Subjects { get; set; }
        public DbSet<BedRoom> Bedrooms { get; set; }
        public DbSet<Book> Books { get; set; }
        public DbSet<Course> Courses { get; set; }
        public DbSet<OfficeRoom> OfficeRooms { get; set;}

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            //一张一张表添加
            //new RoleEntityConfig().Configure(modelBuilder.Entity<Role>());


            //批量添加
            modelBuilder.ApplyConfigurationsFromAssembly(typeof(RoleEntityConfig).Assembly);

        }
    }
}

